{% extends "_base.html" %}


{% block  title %}用户权限管理{% endblock %}


{% block left %}
    {% include "_left.html" with cmdb_user_active="active" %}
{% endblock left %}



{% block page-content %}


    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>资产管理</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="/">主页</a>
                </li>
                <li>用户权限</a>
                </li>
                <li class="active">
                    <strong>(用户/组)列表</strong>
                </li>
            </ol>
        </div>
        <div class="col-lg-2">

        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>用户/组列表</h5>

                    </div>
                    <div class="ibox-content">

                        <div class="table-responsive">

                            <a href="/admin/auth/user/add/" class="btn btn-primary" target="_blank">增加网站用户</a>

                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th class="col-xs-1">名称</th>
                                    <th class="col-xs-4">APP清单</th>
                                    <th class="col-xs-4">主机清单</th>
                                    <th class="col-xs-1">管理</th>
                                    <th class="col-xs-1">后台</th>
                                    <th class="col-xs-1">动作</th>
                                </tr>
                                </thead>
                                <tbody>

                                {% for   row   in   user_list %}

                                    <tr class="gradeA" id="{{ row.id }}">
                                        <td class="center">
                                            <a href="{% url 'cmdb:user_edit' row.id %}">{{ row.username }}</a>
                                        </td>
                                        <td>
                                        {% for i in row.app_set.all|slice:":5" %}
                                            <i class="fa fa-bell-o"></i> {{ i }}<br/>
                                        {% if row.app_set.all|length > 5 and forloop.last %}
                                            …………<br/>
                                            (共有 {{ row.app_set.all|length }} 个APP)
                                        {% endif %}
                                        {% empty %}
                                            未设置
                                        {% endfor %}
                                        </td>
                                        <td>
                                        {% for i in row.host_set.all|slice:":5" %}
                                            <i class="fa fa-laptop"></i> {{ i }}<br/>
                                        {% if row.host_set.all|length > 5 and forloop.last %}
                                            …………<br/>
                                            (共有 {{ row.host_set.all|length }} 台主机)
                                        {% endif %}
                                        {% empty %}
                                            未设置
                                        {% endfor %}
                                        </td>
                                        <td><i class="fa fa-{% if row.is_superuser %}check-square text-navy{% else %}minus-square text-danger{% endif %}"></i></td>
                                        <td><i class="fa fa-{% if row.is_staff %}check-square text-navy{% else %}minus-square text-danger{% endif %}"></i></td>
                                        <td>
                                            <a class="btn btn-primary  btn-xs " href="/admin/auth/user/{{ row.id }}/change/" target="_blank">详细信息</a>

                                        </td>
                                    </tr>
                                {% endfor %}
                                    <tr><td colspan="6"></td></tr>

                                {% for   row   in   group_list %}

                                    <tr class="" id="{{ row.id }}">
                                        <td class="center">
                                            <a href="{% url 'cmdb:usergroup_edit' row.id %}">{{ row.name }}</a>
                                        </td>
                                        <td>
                                        {% for i in row.app_set.all|slice:":5" %}
                                            <i class="fa fa-bell-o"></i> {{ i }}<br/>
                                        {% if row.app_set.all|length > 5 and forloop.last %}
                                            …………<br/>
                                            (共有 {{ row.app_set.all|length }} 个APP)
                                        {% endif %}
                                        {% empty %}
                                            未设置
                                        {% endfor %}
                                        </td>
                                        <td>
                                        {% for i in row.host_set.all|slice:":5" %}
                                            <i class="fa fa-laptop"></i> {{ i }}<br/>
                                        {% if row.host_set.all|length > 5 and forloop.last %}
                                            …………<br/>
                                            (共有 {{ row.host_set.all|length }} 台主机)
                                        {% endif %}
                                        {% empty %}
                                            未设置
                                        {% endfor %}
                                        </td>
                                        <td class="center"></td>
                                        <td class="center"></td>
                                        <td>
                                            <a class="btn btn-primary  btn-xs " href="/admin/auth/group/{{ row.id }}/change/" target="_blank">详细信息</a>

                                        </td>
                                    </tr>
                                {% endfor %}

                                </tbody>

                            </table>


                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>



{% endblock %}


